package com.efast.dmom.mgmt.controller.master;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.dmom.mgmt.bean.mes.WorkOrderInfoDto;
import com.efast.dmom.mgmt.service.master.TmBasStationService;

@Controller
@RequestMapping(value="/tmBasStation")
public class TmBasStationController {
	@Autowired
	private TmBasStationService tmBasStationService;
	
	//获取所有工位
	@RequestMapping(value = "/getAllStation")
	public @ResponseBody ResultBean getAllStation(){
		ResultBean result=new ResultBean(true,"'");
		try {
			List<WorkOrderInfoDto> stationList = new ArrayList<WorkOrderInfoDto>();
			
			//TODO filter station with no shop, production line , station
			for(WorkOrderInfoDto stationInfo : tmBasStationService.getAllStation()){
				if(stationInfo.getLineName() == null || "".equals(stationInfo.getLineName()) || stationInfo.getStationName() == null || "".equals(stationInfo.getStationName())){
					continue;
				}
				stationList.add(stationInfo);
			}
			
			result.setObject(stationList);
		} catch (Exception e) {
			result.setSuccess(false);
			e.printStackTrace();
		}
		return result;
	}
}
